//
//  TSUnit.m
//  XiaoZhen
//
//  Created by 易金鑫 on 17/6/24.
//  Copyright © 2017年 Toocms. All rights reserved.
//

#import "TSUnit.h"

@implementation TSUnit
//流式布局
-(CGFloat)GetCollectionViewHeight:(NSArray *)titleArray titleFont:(CGFloat )titleFont Kwidth:(CGFloat )kwidth Xspace:(CGFloat)xspace Yspace:(CGFloat)yspace LabelXspace:(CGFloat)labelXspace LabelYspace:(CGFloat)LabelYspace CellXspace:(CGFloat)cellXspace CellYspace:(CGFloat)cellYspace{
    int bianju = 2;//视图的边框为1像素 。上下 － 左右对应一对
    int row = 0;
    CGFloat width = -xspace;
    //    TSLog(kScreenWidth);
    for (NSString *str in titleArray) {

        CGSize size = [NSString sizeWithText:str font:[UIFont systemFontOfSize:titleFont] maxW:kwidth - cellXspace];
        width = width + size.width + bianju + labelXspace + xspace;
        if (width > kwidth - cellXspace) {
            width = size.width + bianju + labelXspace + xspace;
            row += 1;

        }
    }
    if (titleArray.count != 0) {
        row += 1;
    }
    CGSize size1 = [NSString sizeWithText:@"234" font:[UIFont systemFontOfSize:titleFont] maxW:kwidth - cellXspace];
    CGFloat Height = row * (size1.height + LabelYspace + yspace) - yspace + cellYspace ;
    return Height;
}
@end
